<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class mgif extends MY_Model {

    var $theme_data = array(
        'layout_main' => 'layout',
        'left' => 'include/leftcp',
    );
    public $mytable = "gif";
    public $primaryKey = "gif_id";
    public $resCode = "GIF";

    function __construct() {
        parent::__construct();
    }

    function field() {
		$fieldData = array();
		$fieldData['gif_name'] = '';
		$fieldData['gif_description'] = '';
		$fieldData['gif_link'] = '';
		$fieldData['gif_date'] = 0;
		$fieldData['gif_user'] = 0;
		return $fieldData;
    }
	
	function get_last($limit = 1) {
		return $this->db
			->limit($limit)
			->order_by($this->primaryKey . " desc")
			->get($this->mytable)
			->first_row();
	}
	
	/**
	 * get older
	 */
	function get_next($id) {
		$id = (int) $id;
		return $this->db
		->limit(1)
		->where($this->primaryKey . " < ", $id)
		->order_by($this->primaryKey . " desc")
		->get($this->mytable)
		->first_row();
	}
	/**
	 * get newer
	 */
	function get_prev($id) {
		$id = (int) $id;
		return $this->db
		->limit(1)
		->where($this->primaryKey . " > ", $id)
		->order_by($this->primaryKey . " desc")
		->get($this->mytable)
		->first_row();
	}
}